<%@ Page StylesheetTheme="Skin1" Language="C#" MasterPageFile="~/LTR/MlyLtrMaster.Master"
    AutoEventWireup="true" CodeBehind="contractorSearch.aspx.cs" Inherits="MLY.LTR.contractorSearch"
    Title='<%$Dict:contractorSearch.Title %>' %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content2" ContentPlaceHolderID="titleHolder" runat="server">
<script type="text/ecmascript">
    function doValidate(sender, args) 
    {
        args.IsValid = false;
        var str1 = $('#<%= contractorName.ClientID %>').val();
        var str2 = $('#<%= txtTag.ClientID %>').val();
        var ddl = $('#<%= ddlClassification.ClientID %>').attr("selectedIndex");
        if (str1.length < 2 && str2.length < 2 && ddl == 0)
            args.IsValid = false;
        else
            args.IsValid = true;
       
    }
</script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <div id="win-xp" class="searchDiv">
        <asp:Literal runat="server" ID="orgNameLit" Text='<%$ Dict:contractorSearch.orgName %>'></asp:Literal>
        &nbsp
        <asp:TextBox runat="server" CssClass="orgNameTxt" ID="contractorName"></asp:TextBox>
        &nbsp
        <table border="0" cellpadding="0" cellspacing="0" class="comboTable">
            <tr style="height: 70px; vertical-align: middle;">
                <td>
                    <asp:Literal runat="server" ID="Literal1" Text='<%$ Dict:contractorSearch.classificationName %>' />
                </td>
                <td>
                    <div style="">
                        <asp:DropDownList ID="ddlClassification" runat="server" CssClass="filterDdl" DataSourceID="LinqDataSource1"
                            DataTextField="ClassificationDescription" DataValueField="ClassificationId" OnLoad="ddlClassification_Load"
                            AutoPostBack="True">
                        </asp:DropDownList>
                    </div>
                </td>
                <td>
                    <asp:Literal runat="server" ID="Literal3" Text='<%$ Dict:contractorSearch.Tag %>'></asp:Literal>
                </td>
                <td>
                    <asp:TextBox CssClass="tagCss" ID="txtTag" runat="server" />
                </td>
            </tr>
        </table>
        <div style="margin-left: 480px">
            <asp:Button runat="server" ID="submitMe" CssClass="smallBtn Btn" Text='<%$ Dict:contractorSearch.submitBtn %>'
                OnClick="submitMe_Click" />
        </div>
        <br />
       
        <asp:Button runat="server" CssClass="largeBtn Btn" CausesValidation="false" PostBackUrl="~/LTR/SubContractorCard.aspx?ContractorId=-1"
            Text='<%$ Dict:contractorSearch.AddContractor %>' />
        &nbsp
        <img src="../Images/line_devision-between-buttun.png" height="17" />
        &nbsp
        <asp:Button runat="server" CausesValidation="false" CssClass="largeBtn Btn" ID="hyperlinqAddClient" Text='<%$ Dict:contractorSearch.AddClient %>'
            PostBackUrl="~/LTR/ClientsCard.aspx?ClientId=-1" />
        <br />
        <br />
        <asp:GridView ID="GridView1" SkinID="GridViewSkin" runat="server" CssClass="customGrid resGrid"
            DataSourceID="ObjectDataSource1" PageSize="3" CellSpacing="0">
           
            <Columns>
            
                <asp:TemplateField  ControlStyle-Width="268"
                    ItemStyle-Width="268" HeaderText='<%$ Dict:contractorSearch.orgNameResults %>'>
                    <ItemTemplate>
                        <asp:Label ID="OrganizationNameLabel" runat="server" Text='<%# Eval("Key.OrganizationName") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField ControlStyle-Width="264" 
                    ItemStyle-Width="264" HeaderText='<%$ Dict:contractorSearch.orgSite %>'>
                    <ItemTemplate>
                        <a href='#' style=" color:blue; text-decoration:underline;" onclick="javascript:window.open('http://<%# Eval("Key.WebSite") %>','<%# Eval("Key.OrganizationName") %>')">
                            <%# Eval("Key.WebSite")%></a></ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField  HeaderText='<%$ Dict:contractorSearch.relationNum %>' ControlStyle-Width="274"
                    ItemStyle-Width="274">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("Value") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="GetContractorsForSearch" TypeName="MLY.Bll.clsOrganization">
            <SelectParameters>
                <asp:ControlParameter ControlID="contractorName" Name="prefix" PropertyName="Text"
                    Type="String" DefaultValue="%" />
                <asp:ControlParameter ControlID="ddlClassification" DefaultValue="0" Name="classificationId"
                    PropertyName="SelectedValue" Type="Int32" />
                <asp:ControlParameter ControlID="txtTag" DefaultValue="%" Name="Tag" PropertyName="Text"
                    Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
    </div>
    <asp:CustomValidator ID="CustomValidator1" ClientValidationFunction="doValidate" EnableClientScript="true" ErrorMessage='<%$ Dict:contractorSearch.UserDidntSelectEnoughParameters %>'
 Display="Dynamic" runat="server" ForeColor="Red"></asp:CustomValidator>
    <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="MLY.Dal.lqKbmDataContext"
        TableName="LookupClassifications">
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="LinqDataSource2" runat="server" ContextTypeName="MLY.Dal.lqKbmDataContext"
        OnSelecting="LinqDataSource2_Selecting" TableName="Dicts">
    </asp:LinqDataSource>
</asp:Content>
